package com.pk.platform.business.charge.service.impl;

import com.pk.platform.business.charge.dao.IIncomeExpenseIndexDao;
import com.pk.platform.business.charge.service.IIncomeExpenseIndexService;
import com.pk.platform.domain.charge.IncomeExpenseIndex;
import com.pk.platform.util.constant.Constant;
import com.pk.platform.util.page.ListPage;
import com.pk.platform.util.page.Pager;

public class IncomeExpenseIndexServiceImpl implements IIncomeExpenseIndexService {

	private IIncomeExpenseIndexDao incomeExpenseIndexDao;
	
	public ListPage queryIncomeExpenseIndex(IncomeExpenseIndex iei, Pager pager) {
		return incomeExpenseIndexDao.queryIncomeExpenseIndex(iei, pager);
	}
	
	public String addIncomeExpenseIndex(IncomeExpenseIndex iei) {
		incomeExpenseIndexDao.add(iei);
		incomeExpenseIndexDao.addOperateLog("新增其他收入与支出费用指标", Constant.SUCCESSFUL, null);
		return Constant.SUCCESS;
	}
	
	
	
	public void delIncomeExpenseIndex(String id) {
		IncomeExpenseIndex iei = queryIncomeExpenseIndexById(id);
		incomeExpenseIndexDao.addOperateLog("删除其他收入与支出费用指标", Constant.SUCCESSFUL, null);
		if(incomeExpenseIndexDao.existIndexData(id))
		{
			iei.setIsDel(Constant.Y_INT);
			incomeExpenseIndexDao.update(iei);
		}
		else
		{
			incomeExpenseIndexDao.delete(IncomeExpenseIndex.class, id);
		}
	}
	
	

	public IncomeExpenseIndex queryIncomeExpenseIndexById(String id) {
		return incomeExpenseIndexDao.get(IncomeExpenseIndex.class, id);
	}
	
	public String updateIncomeExpenseIndex(IncomeExpenseIndex iei) {
		/*IncomeExpenseIndex ieIndex = queryIncomeExpenseIndexById(iei.getId());
		ieIndex.setIndexName(iei.getIndexName());
		ieIndex.setIsDel(iei.getIsDel());
		BaseData bd = new BaseData();
		bd.setId(iei.getType().getId());
		ieIndex.setType(bd);*/
		incomeExpenseIndexDao.update(iei);
		incomeExpenseIndexDao.addOperateLog("修改其他收入与支出费用指标", Constant.SUCCESSFUL, null);
		return Constant.SUCCESS;
	}
	
	public IIncomeExpenseIndexDao getIncomeExpenseIndexDao() {
		return incomeExpenseIndexDao;
	}

	public void setIncomeExpenseIndexDao(
			IIncomeExpenseIndexDao incomeExpenseIndexDao) {
		this.incomeExpenseIndexDao = incomeExpenseIndexDao;
	}
	
	

	
}
